package com.zaixiandiancan.xia.serviceImpl;

import com.zaixiandiancan.xia.dao.GoodsDao;
import com.zaixiandiancan.xia.entity.Goods;
import com.zaixiandiancan.xia.entity.Gtypes;
import com.zaixiandiancan.xia.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service(value = "qrcodeService")
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsDao goodsDao;

    @Override
    public List<Goods> searchGoods(Map<String, Object> g) {
           return goodsDao.searchGoods(g);
    }

    @Override
    @Transactional
    public boolean addGoods(Goods goods) {
        try {
            return goodsDao.addGoods(goods);
        }catch (Exception e){
            return false;
        }
    }

    @Override
    public List<Gtypes> searchTypes() {
        try {
            return goodsDao.searchTypes();
        }catch (Exception e){
            return null;
        }
    }

    @Override
    @Transactional
    public boolean addTypes(Gtypes types) {
        try {
            return goodsDao.addTypes(types);
        }catch (Exception e){
            return false;
        }
    }

	@Override
	public List<Goods> searchGoodsByType(String type) {
		return goodsDao.searchGoodsByType(type);
	}
}
